package com.booktype.action;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.booktype.bean.Booktype;
import com.booktype.service.IBooktypeService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@Controller("booktypeAction")
@Scope("prototype")
public class BooktypeAction extends ActionSupport {
	public void load() {
		ActionContext.getContext().getSession().remove("booktype");
		ActionContext.getContext().getSession().put("booktype", booktypeService.getAllBooktype());
		System.out.println("load booktype");
		HttpServletRequest request = ServletActionContext.getRequest();
		request.setAttribute("allBook", getAllBooktype());
	}
	
	public List<Booktype> getAllBooktype() {
		return booktypeService.getAllBooktype();
	}

	private static final long serialVersionUID = -6212683886988014352L;
	
	@Resource
	private IBooktypeService booktypeService;
}
